package test.h0814;

import java.util.Scanner;
import java.util.StringJoiner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 虚拟理财游戏
 * @date 2024/8/14 21:50
 */
public class Main7 {
    public static void main(String[] args) {
        //第一行：
        //产品数（取值范围[1,20]）
        //总投资额（整数，取值范围[1, 10000]）
        //可接受的总风险（整数，取值范围[1,200]）
        //第二行：产品投资回报率序列，输入为整数，取值范围[1,60]
        //第三行：产品风险值序列，输入为整数，取值范围[1, 100]
        //第四行：最大投资额度序列，输入为整数，取值范围[1, 10000]
        //5 100 10
        //10 20 30 40 50
        //3 4 5 6 10
        //20 30 20 40 30
        Scanner sc = new Scanner(System.in);
        //产品数目
        int n = sc.nextInt();
        //总投资额
        int totalMoney = sc.nextInt();
        //总风险
        int totalRisks = sc.nextInt();

        int[] rates = new int[n]; //投资回报率序列
        for (int i = 0; i < n; i++) {
            rates[i] = sc.nextInt();
        }
        int[] risks = new int[n];
        for (int i = 0; i < n; i++) {
            risks[i] = sc.nextInt();
        }
        int[] invests = new int[n]; //最大投资额度序列
        for (int i = 0; i < n; i++) {
            invests[i] = sc.nextInt();
        }
        int[] res = getResult(rates, risks, invests, n, totalRisks, totalMoney);
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : res) {
            joiner.add(i + "");
        }
        System.out.println(joiner);
    }

    private static int[] getResult(int[] rates, int[] risks, int[] invests, int n, int totalRisks, int totalMoney) {
        int[] ans = new int[n];
        int sum = 0;
        int a = 0;
        int b = 0;
        //只有两个投资序列，使用双层for循环
        for (int i = 0; i < n; i++) {
            if (invests[i] > totalMoney || risks[i] > totalRisks) {
                continue;
            }
            a = invests[i] * rates[i];
            //TODO 这里是如果只有一个投资的情况。
            if (a > sum) {
                sum = a;
                ans = new int[n];
                ans[i] = invests[i];
            }
            int tmpNewInvestJ = totalMoney - invests[i];
            for (int j = 0; j < n; j++) {
                if (i == j || risks[i] + risks[j] > totalRisks) {
                    continue;
                }

                if (tmpNewInvestJ > invests[j]) {
                    b = invests[j] * rates[j];
                } else {
                    b = tmpNewInvestJ * rates[j];
                }
                if (a + b > sum) {
                    sum = a + b;
                    ans = new int[n];
                    ans[i] = invests[i];
                    ans[j] = b/rates[j];
                }
            }
        }
        return ans;

    }
}
